package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.Wenda;
import cn.wolfcode.luowowo.article.mapper.WendaMapper;
import cn.wolfcode.luowowo.article.service.IWendaService;
import cn.wolfcode.luowowo.common.query.QueryObject;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class WendaServiceImpl implements IWendaService {
    @Autowired
    private WendaMapper wendaMapper;

    @Override
    public void save(Wenda wenda ) {
       wendaMapper.insert(wenda);

    }

    @Override
    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Wenda> list =wendaMapper.selectForList(qo);
        return new PageInfo(list);
    }

    @Override
    public Wenda queryById(Long id) {
        return wendaMapper.selectByPrimaryKey(id);
    }
}
